home *** CD-ROM | disk | FTP | other *** search
Wrap
Team Developer / SQLWindows application | 1991-01-18 | 33.3 KB | 840 lines
.head 0 + Application Description: Combo Toolbox Demo program. Copyright 1991, Todd Steinwart; Advanced Sales Technologies, Inc. All rights reserved. The version of this application that comes with the release DLL contains more fully anotated code. In this sample code, notation is provided where necessary for you to understand the basics of the DLL operation and its use in SQLWindows. *** The database is NOT required for this demonstration. *** This sample program is provided As Is, and no warranty is made as to its fitness for any purpose other than that of demonstration. We will be happy to answer any non-technical questions you have during your evaluation of this demo system, and provide you with full support once you have purchased the release version. As explained in the About box text, you may make 100 calls to the DLL during a single run of your application. After that, the DLL will return CB_ERR for any call you make except ComboBoxCreate. YOU *MUST* CHECK THE RETURN CODE FOR ANY FUNCTION RETURNING A VALUE BEFORE USING IT ELSEWHERE. THE VALUE CB_ERR IS NEGATIVE AND AN ATTEMPT TO USE IT AS AN INDEX INTO A SQLWINDOWS ARRAY WILL CAUSE A SQLWINDOWS ABEND. Thank you for your trial of this product. It has become an essential part of our SQLWindows arsenal and we hope that it will find its way into yours until such a time that Gupta Technologies makes combo boxes a standard SQLWindows control. We also provide SQLWindows consulting and development services and have developed numerous other SQLWindows "tricks and techniques" that we may make available in the future. If you have ideas for advancing the SQLWindows interface but not the expertise with the Windows SDK, talk to us. We may be able to help.... Todd Steinwart 1(919)942-2067 Gregg Morris 1(404)552-7739 SQLWindows and SQLBase are registered trademarks of Gupta Technologies, Inc. Microsoft and Windows are registered trademarks of Microsoft Corporation. .head 1 + Design-time Settings .head 2 - Outline Window State: Normal .head 2 + Outline Window Location and Size .head 3 - Left: 0.029" .head 3 - Top: 0.063" .head 3 - Width: 11.4" .head 3 - Height: 5.729" .head 2 + Options Box Location .head 3 - Visible? No .head 3 - Left: 4.0" .head 3 - Top: 2.583" .head 2 - Fully Qualified External References? No .head 1 + Global Declarations .head 2 + External Functions .head 3 + Library name: SQLWIN01.EXE .head 4 + Function: SalCreateWindow .head 5 - Description: Create a window instance. hWndNew = SalCreateWindow( Template, hWndParent ) .head 5 - Export Ordinal: 28 .head 5 + Returns .head 6 - Window Handle: HWND .head 5 + Parameters .head 6 - Template: TEMPLATE .head 6 - Window Handle: HWND .head 4 + Function: SalHideWindow .head 5 - Description: Hide a window. bOk = SalHideWindow( hWndToHide ) .head 5 - Export Ordinal: 23 .head 5 + Returns .head 6 - Boolean: BOOL .head 5 + Parameters .head 6 - Window Handle: HWND .head 4 + Function: SalMessageBeep .head 5 - Description: Beep when a message box is displayed. bOk = SalMessageBeep( nMsgBoxFlags ) .head 5 - Export Ordinal: 170 .head 5 + Returns .head 6 - Boolean: BOOL .head 5 + Parameters .head 6 - Number: WORD .head 4 + Function: SalMessageBox .head 5 - Description: Display message box, return button response. nResult = SalMessageBox( strText, strTitle, nFlags ) .head 5 - Export Ordinal: 24 .head 5 + Returns .head 6 - Number: INT .head 5 + Parameters .head 6 - String: LPSTR .head 6 - String: LPSTR .head 6 - Number: WORD .head 4 + Function: SalPostMsg .head 5 - Description: Post a message to a window. bOk = SalPostMsg( hWndReceiver, nMsg, nMywParam, nMylParam ) .head 5 - Export Ordinal: 26 .head 5 + Returns .head 6 - Boolean: BOOL .head 5 + Parameters .head 6 - Window Handle: HWND .head 6 - Number: WORD .head 6 - Number: WORD .head 6 - Number: LONG .head 4 + Function: SalSendMsg .head 5 - Description: Send a message to a window. nMsgReturn = SalSendMsg( hWnd, mMsg, nMywParam, nMylParam ) .head 5 - Export Ordinal: 25 .head 5 + Returns .head 6 - Number: LONG .head 5 + Parameters .head 6 - Window Handle: HWND .head 6 - Number: WORD .head 6 - Number: WORD .head 6 - Number: LONG .head 4 + Function: SalSetWindowText .head 5 - Description: Set the caption title of Form or Dialog, or contents of form item. bOK = SalSetWindowText( hWnd, strTitle ) .head 5 - Export Ordinal: 40 .head 5 + Returns .head 6 - Boolean: BOOL .head 5 + Parameters .head 6 - Window Handle: HWND .head 6 - String: LPSTR .head 4 + Function: SalShowWindow .head 5 - Description: Make a window visible. bOk = SalShowWindow( hWndToShow ) .head 5 - Export Ordinal: 22 .head 5 + Returns .head 6 - Boolean: BOOL .head 5 + Parameters .head 6 - Window Handle: HWND .head 4 + Function: SalGetWindowText .head 5 - Description: Get the caption title of Form or Dialog, or contents of form item. nLength = SalGetWindowText( hWnd, strText, nMaxlen ) .head 5 - Export Ordinal: 39 .head 5 + Returns .head 6 - Number: INT .head 5 + Parameters .head 6 - Window Handle: HWND .head 6 - Receive String: LPHSTRING .head 6 - Number: INT .head 4 + Function: SalStrSetBufferLength .head 5 - Description: Set the length of the given string buffer. bOK = SalStrSetBufferLength( strString, nLength ) .head 5 - Export Ordinal: 96 .head 5 + Returns .head 6 - Boolean: BOOL .head 5 + Parameters .head 6 - Receive String: LPHSTRING .head 6 - Number: LONG .head 4 + Function: SalNumberToStr .head 5 - Description: Convert a number to a string. nLength = SalNumberToStr( nNumber, nDecimalPlaces, strString ) .head 5 - Export Ordinal: 150 .head 5 + Returns .head 6 - Number: INT .head 5 + Parameters .head 6 - Number: NUMBER .head 6 - Number: INT .head 6 - Receive String: LPHSTRING .head 4 + Function: SalQuit .head 5 - Description: Quit the application. bOK = SalQuit() .head 5 - Export Ordinal: 31 .head 5 + Returns .head 6 - Boolean: BOOL .head 5 - Parameters .head 4 + Function: SalModalDialog .head 5 - Description: Create a modal dialog box. nReturn = SalModalDialog( Template, hWndOwner ) .head 5 - Export Ordinal: 46 .head 5 + Returns .head 6 - Number: INT .head 5 + Parameters .head 6 - Template: TEMPLATE .head 6 - Window Handle: HWND .head 4 + Function: SalEndDialog .head 5 - Description: End a modal dialog. bOk = SalEndDialog( hWndModal, nReturn ) .head 5 - Export Ordinal: 47 .head 5 + Returns .head 6 - Boolean: BOOL .head 5 + Parameters .head 6 - Window Handle: HWND .head 6 - Number: INT .head 4 + Function: SalSetFocus .head 5 - Description: Set the focus to the given window. hWndOldFocus = SalSetFocus( hWndToSet ) .head 5 - Export Ordinal: 175 .head 5 + Returns .head 6 - Window Handle: HWND .head 5 + Parameters .head 6 - Window Handle: HWND .head 3 + Library name: CBDEMO.DLL .head 4 + Function: ComboBoxAdd .head 5 - Description: nNewIndex = ComboBoxAdd( hWndComboBox, sAddString ) .head 5 - Export Ordinal: 1 .head 5 + Returns .head 6 - Number: INT .head 5 + Parameters .head 6 - Window Handle: HWND .head 6 - String: LPSTR .head 4 + Function: ComboBoxSelectString .head 5 - Description: nIndex = ComboBoxSelectString( hWndComboBox, nStartPos, sPrefix ) .head 5 - Export Ordinal: 2 .head 5 + Returns .head 6 - Number: INT .head 5 + Parameters .head 6 - Window Handle: HWND .head 6 - Number: INT .head 6 - String: LPSTR .head 4 + Function: ComboBoxQuerySelection .head 5 - Description: nIndex = ComboBoxQuerySelection( hWndComboBox ) .head 5 - Export Ordinal: 3 .head 5 + Returns .head 6 - Number: INT .head 5 + Parameters .head 6 - Window Handle: HWND .head 4 + Function: ComboBoxQueryText .head 5 - Description: ComboBoxQueryText( hWndComboBox, nIndex, rsText ) .head 5 - Export Ordinal: 4 .head 5 + Returns .head 6 - Number: INT .head 5 + Parameters .head 6 - Window Handle: HWND .head 6 - Number: INT .head 6 - Receive String: LPSTR .head 4 + Function: ComboBoxClear .head 5 - Description: Call ComboBoxClear( hWndComboBox ) .head 5 - Export Ordinal: 5 .head 5 - Returns .head 5 + Parameters .head 6 - Window Handle: HWND .head 4 + Function: ComboBoxQueryCount .head 5 - Description: set nCount = ComboBoxQueryCount( hWndComboBox ) .head 5 - Export Ordinal: 6 .head 5 + Returns .head 6 - Number: INT .head 5 + Parameters .head 6 - Window Handle: HWND .head 4 + Function: ComboBoxDelete .head 5 - Description: set nRemainingCount = ComboBoxDelete( hWndComboBox, nIndex ) .head 5 - Export Ordinal: 7 .head 5 + Returns .head 6 - Number: INT .head 5 + Parameters .head 6 - Window Handle: HWND .head 6 - Number: INT .head 4 + Function: ComboBoxQueryTextLength .head 5 - Description: set nTextLength = ComboBoxQueryTextLength( hWndComboBox, nIndex ) .head 5 - Export Ordinal: 8 .head 5 + Returns .head 6 - Number: INT .head 5 + Parameters .head 6 - Window Handle: HWND .head 6 - Number: INT .head 4 + Function: ComboBoxSetSelect .head 5 - Description: Call ComboBoxSetSelect( hWndComboBox, nIndex ) .head 5 - Export Ordinal: 9 .head 5 + Returns .head 6 - Number: INT .head 5 + Parameters .head 6 - Window Handle: HWND .head 6 - Number: INT .head 4 + Function: ComboBoxInsert .head 5 - Description: set nPos = ComboBoxInsert( hWndComboBox, nPos, sText ) .head 5 - Export Ordinal: 10 .head 5 + Returns .head 6 - Number: INT .head 5 + Parameters .head 6 - Window Handle: HWND .head 6 - Number: INT .head 6 - String: LPSTR .head 4 + Function: ComboBoxShowDropdown .head 5 - Description: Call ComboBoxShowDropdown( hWndComboBox, bState ) .head 5 - Export Ordinal: 11 .head 5 - Returns .head 5 + Parameters .head 6 - Window Handle: HWND .head 6 - Boolean: BOOL .head 4 + Function: ComboBoxLimitTextLength .head 5 - Description: Set bOk = ComboBoxLimitTextLength( hWndComboBox, nTextLength ) .head 5 - Export Ordinal: 12 .head 5 + Returns .head 6 - Boolean: BOOL .head 5 + Parameters .head 6 - Window Handle: HWND .head 6 - Number: INT .head 4 + Function: ComboBoxCreate .head 5 - Description: hWndComboBox = ComboBoxCreate( hWndParent, hWndTemplate, nID, nCBType, bSort, nLBRows) .head 5 - Export Ordinal: 13 .head 5 + Returns .head 6 - Window Handle: HWND .head 5 + Parameters .head 6 - Window Handle: HWND .head 6 - Window Handle: HWND .head 6 - Number: WORD .head 6 - Number: DWORD .head 6 - Boolean: BOOL .head 6 - Number: INT .head 4 + Function: ComboBoxFindString .head 5 - Description: nIndex = ComboBoxFindString( hWndComboBox, nStartPos, sPrefix ) .head 5 - Export Ordinal: 14 .head 5 + Returns .head 6 - Number: INT .head 5 + Parameters .head 6 - Window Handle: HWND .head 6 - Number: INT .head 6 - String: LPSTR .head 2 + Constants .head 3 + System .head 4 - ! Standard Boolean constants .head 4 - Boolean: FALSE = 0 .head 4 - Boolean: TRUE = 1 .head 4 - ! SAM messages .head 4 - Number: SAM_AppStartup = 0x2001 .head 4 - Number: SAM_Click = 0x2006 .head 4 - Number: SAM_Close = 0x0010 .head 4 - Number: SAM_Create = 0x1001 .head 4 - Number: SAM_Destroy = 0x1002 .head 4 - ! Start constant for user-defined messages .head 4 - Number: SAM_User = 0x4000 .head 4 - ! Flag options for SalMessageBox .head 4 - Number: MB_Ok = 0x0000 .head 4 - Number: MB_OkCancel = 0x0001 .head 4 - Number: MB_AbortRetryIgnore = 0x0002 .head 4 - Number: MB_YesNoCancel = 0x0003 .head 4 - Number: MB_YesNo = 0x0004 .head 4 - Number: MB_RetryCancel = 0x0005 .head 4 - Number: MB_IconHand = 0x0010 .head 4 - Number: MB_IconQuestion = 0x0020 .head 4 - Number: MB_IconExclamation = 0x0030 .head 4 - Number: MB_IconAsterisk = 0x0040 .head 4 - Number: MB_DefButton1 = 0x0000 .head 4 - Number: MB_DefButton2 = 0x0100 .head 4 - Number: MB_DefButton3 = 0x0200 .head 4 - Number: MB_ApplModal = 0x0000 .head 4 - Number: MB_SystemModal = 0x1000 .head 4 - Number: MB_NoFocus = 0x8000 .head 4 - ! Return values for SalMessageBox .head 4 - Number: IDABORT = 3 .head 4 - Number: IDCANCEL = 2 .head 4 - Number: IDIGNORE = 5 .head 4 - Number: IDNO = 7 .head 4 - Number: IDOK = 1 .head 4 - Number: IDRETRY = 4 .head 4 - Number: IDYES = 6 .head 3 + User .head 4 - Number: WM_COMMAND =0x0111 .head 4 - Number: WM_LBUTTONDOWN=0x0201 .head 4 - Number: WM_LBUTTONUP=0x0202 .head 4 - Number: WM_RBUTTONDOWN=0x0204 .head 4 - Number: WM_RBUTTONUP=0x0205 .head 4 - Number: TDS_CreateDone = SAM_User .head 4 - ! -------------------------------------- Window styles .head 4 - Number: CBS_SIMPLE = 1 .head 4 - Number: CBS_DROPDOWN = 2 .head 4 - Number: CBS_DROPDOWNLIST = 3 .head 4 - Number: CBS_AUTOHSCROLL = 0X40 .head 4 - ! -------------------------------------- Combo box return values .head 4 - Number: CB_OKAY = 0 .head 4 - Number: CB_ERR =- 1 .head 4 - Number: CB_ERRSPACE = -2 .head 4 - ! -------------------------------------- Combo box notification codes .head 4 - Number: CBN_ERRSPACE = -1 .head 4 - Number: CBN_SELCHANGE = 1 .head 4 - Number: CBN_DBLCLK = 2 .head 4 - Number: CBN_SETFOCUS = 3 .head 4 - Number: CBN_KILLFOCUS = 4 .head 4 - Number: CBN_EDITCHANGE = 5 .head 4 - Number: CBN_EDITUPDATE = 6 .head 4 - Number: CBN_DROPDOWN = 7 .head 4 - ! .head 4 - Number: IDC_SIMPLE = 128 .head 4 - Number: IDC_DROPDOWNLIST = 129 .head 4 - Number: IDC_DROPDOWN = 130 .head 4 - String: ABOUT_TEXT='Welcome! The purpose of the Combo Toolbox is to provide you, the SQLWindows developer, and your users with a tool for the creation and manipulation of genuine, straight-from-the-heart-of-Windows Combo Boxes. We have worked hard to create an efficient, easy-to-use Dynamic Link Library (DLL) and would now like to make it available to the SQLWindows developers\' community. This demo version provides you with complete, but limited, access to the DLL. We have also provided a sample APP that you can examine to determine if you think you can use the Combo Toolbox. You are free to create your own applications with this demo version, but you are restricted as described in the next paragraph and you will not receive technical support. We will, however, be quite happy to answer any questions you have about the product. Purchase of the product entitles you to: 1. An uncrippled version of the DLL. 2. A complete, fully annotated application, with examples showing you how you manipulate the various types of combo boxes. 3. Documentation. 4. Technical support In order to protect our investment of time and energy the development of this product, the supplied CBDEMO.DLL has been crippled as follows: 1. Each time you start the supplied application, or any application you create for test purposes, you receive 100 "tickets" from the DLL. Each access to the DLL will cost you one of those tickets. When all of your tickets are gone, the DLL will return CB_ERR for any call you make. If you are writing your own test apps, be sure to check for error values returning from the combobox calls! 2. The ComboboxShowDropDown, ComboboxInsert and ComboboxClear functions have been disabled. The cost for the complete package is only $50.00. This buys you a single-use license of the DLL, documentation and support. We have a very reasonable licensing policy for the distribution of the DLL, with a per-machine cost as low as $2.00! Please call for details. Thank you for evaluating this product.' .head 2 + Variables .head 3 - Window Handle: hWndNULL .head 3 - Window Handle: hWndForm .head 3 - Window Handle: hWndItem .head 3 - Number: wParam .head 3 - Number: lParam .head 3 - Number: nArgCount .head 3 - String: strArgArray[*] .head 3 - ! Database name: default = DEMO .head 3 - String: SqlDatabase .head 3 - ! Authorization name: default = SYSADM .head 3 - String: SqlUser .head 3 - ! Password: default = SYSADM .head 3 - String: SqlPassword .head 3 - ! APPLICATION STUFF. NOTHING REQUIRED FOR BASIC COMBOBOX MANIPULATION .head 3 - String: Cities[10] .head 3 - Window Handle: hWndMain .head 2 + Internal Functions .head 3 + Function: InstallCities .head 4 - Description: Stuffs the Cities array {Find myself a city to live in...} .head 4 - Returns .head 4 - Parameters .head 4 - Local variables .head 4 + Actions .head 5 - Set Cities[0]='Tokyo' .head 5 - Set Cities[1]='Rome' .head 5 - Set Cities[2]='London' .head 5 - Set Cities[3]='Berlin' .head 5 - Set Cities[4]='Atlanta' .head 5 - Set Cities[5]='New York' .head 5 - Set Cities[6]='Carrboro' .head 5 - Set Cities[7]='Menlo Park' .head 5 - Set Cities[8]='Sydney' .head 5 - Set Cities[9]='Cairo' .head 2 + Application Actions .head 3 + On SAM_AppStartup .head 4 - Call InstallCities() .head 4 - Set hWndMain= SalCreateWindow( Main, hWndNULL ) .head 1 + Form Window: Main .head 2 - Title: A Comprehensive Combo Box Gallery .head 2 - Icon File: cbdemo.ico .head 2 + Display Settings .head 3 - Visible at Design time? No .head 3 - Automatically Created at Runtime? No .head 3 - Initial State: Normal .head 3 - Maximizable? No .head 3 - Minimizable? Yes .head 3 - System Menu? Yes .head 3 - Resizable? No .head 3 + Window Location and Size .head 4 - Left: 0.071" .head 4 - Top: 0.906" .head 4 - Width: 8.6" .head 4 - Height: 2.563" .head 3 + Form Size .head 4 - Width: Default .head 4 - Height: Default .head 4 - Number of Pages: Dynamic .head 2 + Menu .head 3 + Popup Menu: &File .head 4 - Enabled when: .head 4 + Menu Item: E&xit .head 5 - Keyboard Accelerator: (none) .head 5 + Menu Settings .head 6 - Enabled when: .head 6 - Checked when: .head 5 + Menu Actions .head 6 - Return SalQuit() .head 4 + Menu Item: A&bout... .head 5 - Keyboard Accelerator: (none) .head 5 + Menu Settings .head 6 - Enabled when: .head 6 - Checked when: .head 5 + Menu Actions .head 6 - Call SalModalDialog( dlgAbout, hWndForm ) .head 2 + Contents .head 3 - ! These three data fields serve as "templates" for the combo boxes. They MUST .head 3 - ! be configured as they are here: noneditable, invisible and borderless. The .head 3 - ! DLL uses these fields to size and position the combo boxes when they are created. .head 3 - ! When the field is created (On SAM_Create) you must set a window handle to the .head 3 - ! value of hWndItem. .head 3 + Data Field: fSimple .head 4 + Data .head 5 - Maximum Data Length: Default .head 5 - Data Type: String .head 5 - Editable? No .head 4 + Display Settings .head 5 + Window Location and Size .head 6 - Left: 0.886" .head 6 - Top: 0.406" .head 6 - Width: 1.9" .head 6 - Height: 0.25" .head 5 - Visible? No .head 5 - Border? No .head 5 - Justify: Left .head 5 - Format: Unformatted .head 5 - Country: Default .head 4 + Message Actions .head 5 + On SAM_Create .head 6 - Set hWndChildSimple = hWndItem .head 6 - Call SalHideWindow( hWndItem ) .head 3 + Data Field: fDropDownList .head 4 + Data .head 5 - Maximum Data Length: Default .head 5 - Data Type: String .head 5 - Editable? No .head 4 + Display Settings .head 5 + Window Location and Size .head 6 - Left: 3.186" .head 6 - Top: 0.406" .head 6 - Width: 1.9" .head 6 - Height: 0.25" .head 5 - Visible? No .head 5 - Border? No .head 5 - Justify: Left .head 5 - Format: Unformatted .head 5 - Country: Default .head 4 + Message Actions .head 5 + On SAM_Create .head 6 - Set hWndChildDropDownList = hWndItem .head 6 - Call SalHideWindow( hWndItem ) .head 3 + Data Field: fDropDown .head 4 + Data .head 5 - Maximum Data Length: Default .head 5 - Data Type: String .head 5 - Editable? No .head 4 + Display Settings .head 5 + Window Location and Size .head 6 - Left: 5.786" .head 6 - Top: 0.406" .head 6 - Width: 1.9" .head 6 - Height: 0.25" .head 5 - Visible? No .head 5 - Border? No .head 5 - Justify: Left .head 5 - Format: Unformatted .head 5 - Country: Default .head 4 + Message Actions .head 5 + On SAM_Create .head 6 - Set hWndChildDropDown = hWndItem .head 6 - Call SalHideWindow( hWndItem ) .head 3 + Background Text: City: .head 4 + Window Location and Size .head 5 - Left: 0.086" .head 5 - Top: 0.448" .head 5 - Width: 0.529" .head 5 - Height: 0.177" .head 4 - Visible? Yes .head 4 - Justify: Left .head 3 + Background Text: CBS_SIMPLE .head 4 + Window Location and Size .head 5 - Left: 0.886" .head 5 - Top: 0.115" .head 5 - Width: 1.4" .head 5 - Height: 0.177" .head 4 - Visible? Yes .head 4 - Justify: Left .head 3 + Background Text: CBS_DROPDOWNLIST .head 4 + Window Location and Size .head 5 - Left: 3.186" .head 5 - Top: 0.115" .head 5 - Width: 2.2" .head 5 - Height: 0.177" .head 4 - Visible? Yes .head 4 - Justify: Left .head 3 + Background Text: CBS_DROPDOWN .head 4 + Window Location and Size .head 5 - Left: 5.786" .head 5 - Top: 0.115" .head 5 - Width: 2.0" .head 5 - Height: 0.177" .head 4 - Visible? Yes .head 4 - Justify: Left .head 3 + Background Text: Style: .head 4 + Window Location and Size .head 5 - Left: 0.086" .head 5 - Top: 0.115" .head 5 - Width: 0.629" .head 5 - Height: 0.177" .head 4 - Visible? Yes .head 4 - Justify: Left .head 3 + Pushbutton: pbCount .head 4 - Title: Count Items! .head 4 + Window Location and Size .head 5 - Left: 5.786" .head 5 - Top: 1.49" .head 5 - Width: 1.8" .head 5 - Height: 0.292" .head 4 - Visible? Yes .head 4 - Keyboard Accelerator: (none) .head 4 + Message Actions .head 5 + On SAM_Click .head 6 - Set nCount = ComboBoxQueryCount( hWndComboBoxDropDown ) .head 6 + If nCount != CB_ERR .head 7 - Call SalNumberToStr( nCount, 0, sCount ) .head 7 - Call SalMessageBox( 'The CBS_DROPDOWN Combo Box contains '||sCount||' items.', 'Commander Data', MB_Ok|MB_IconAsterisk ) .head 6 + Else .head 7 - Call SalMessageBeep( 0 ) .head 7 - Call SalMessageBox( 'Error returned from ComboBox Call!','Demo',MB_Ok|MB_IconHand ) .head 3 + Multiline Field: mfText .head 4 + Data .head 5 - Maximum Data Length: Default .head 5 - String Type: String .head 5 - Editable? Yes .head 4 + Display Settings .head 5 - Border? Yes .head 5 - Word Wrap? Yes .head 5 - Vertical Scroll? No .head 5 + Window Location and Size .head 6 - Left: 3.186" .head 6 - Top: 0.74" .head 6 - Width: 4.6" .head 6 - Height: 0.667" .head 5 - Visible? Yes .head 4 + Message Actions .head 5 + On SAM_Create .head 6 - Set mfText = 'You may type text here to satisfy any doubts as to the validity of the comboboxes' .head 2 + Window Variables .head 3 - Number: n .head 3 - Window Handle: hWndComboBoxSimple .head 3 - Window Handle: hWndComboBoxDropDownList .head 3 - Window Handle: hWndComboBoxDropDown .head 3 - Window Handle: hWndChildSimple .head 3 - Window Handle: hWndChildDropDownList .head 3 - Window Handle: hWndChildDropDown .head 3 - Number: nIndex .head 3 - String: sSelText .head 3 - String: sWords .head 3 - Number: hiWord .head 3 - Number: nOldIndex .head 3 - String: sRetString .head 3 - String: sButtonText .head 3 - Number: nCount .head 3 - String: sCount .head 3 - Number: nComboBoxRet .head 2 + Message Actions .head 3 + On SAM_Create .head 4 - ! In order to affect a proper window's appearance we'll hide it until we're done .head 4 - ! creating and populating the combo box. See the explanation in the Contents .head 4 - ! section for clarification. .head 4 - Call SalHideWindow( hWndForm ) .head 4 - Call SalPostMsg( hWndForm, TDS_CreateDone, 0, 0 ) .head 3 + On TDS_CreateDone .head 4 - ! Observe here the actual call to the DLL to create the combo boxes. The Description: .head 4 - ! line of the various calls contains an prototype of the function call. .head 4 - ! The two vital pieces of information we need to retain are the window handle returned .head 4 - ! from the ComboBoxCreate call and the ID number that is passed as the third parameter .head 4 - ! to the ComboBoxCreate function. The returned window handle is the window handle .head 4 - ! of the combo box. We'll pass it to any ComboBox___ functions we need to call. The .head 4 - ! ID, which we've defined in the constants section, is how Windows will let us know .head 4 - ! that the user has "touched" in some way the combo box. See the explanation at .head 4 - ! the WM_COMMAND message for more information. .head 4 - ! .head 4 - Set hWndComboBoxSimple = ComboBoxCreate( hWndForm, hWndChildSimple, IDC_SIMPLE, CBS_SIMPLE, TRUE, 6) .head 4 - Set hWndComboBoxDropDownList = ComboBoxCreate( hWndForm, hWndChildDropDownList, IDC_DROPDOWNLIST, CBS_DROPDOWNLIST, TRUE, 6) .head 4 - Set hWndComboBoxDropDown = ComboBoxCreate( hWndForm, hWndChildDropDown, IDC_DROPDOWN, CBS_DROPDOWN, TRUE, 6) .head 4 - ! .head 4 - ! Now we'll populate the comboboxes. Notice the remarkable similarity to SQLWindows' .head 4 - ! listbox (SalList___) functions. .head 4 - Set n=0 .head 4 + While n<=9 .head 5 - Call ComboBoxAdd(hWndComboBoxSimple, Cities[n]) .head 5 - Call ComboBoxAdd(hWndComboBoxDropDownList, Cities[n]) .head 5 - Call ComboBoxAdd(hWndComboBoxDropDown, Cities[n]) .head 5 - Set n=n+1 .head 4 - Call ComboBoxSelectString( hWndComboBoxSimple, 0, 'Carr' ) .head 4 - Call ComboBoxSelectString( hWndComboBoxDropDownList, 0, 'Atl' ) .head 4 - Call ComboBoxSelectString( hWndComboBoxDropDown, 0, 'Men' ) .head 4 - ! Force display of the about box on startup. .head 4 - Call SalModalDialog( dlgAbout, hWndForm ) .head 4 - ! now that all the hocus-pocus is done we can reveal the window. .head 4 - Call SalShowWindow( hWndForm ) .head 3 + On WM_COMMAND .head 4 - ! WHOA! What's *this* message doing here? .head 4 - ! In Windows SDK programming, child controls: list boxes, edit fields, pushbuttons, etc .head 4 - ! do not receive messages of their own. They send a WM_COMMAND message to their _parent_ .head 4 - ! window informing the parent window of which control has been affected by the user .head 4 - ! and what the user's action was. .head 4 - ! Anyone would agree that SQLWindows outlines provide a more accessible alternative .head 4 - ! to humoungous switch statements that C programmers must contend with. .head 4 - ! Unfortunately, we have stepped somewhat out of bounds to create the comboboxes, and .head 4 - ! therefore must also step out of bounds in order to process them. What we've done is .head 4 - ! provide you with a template under which you can tuck your own code quite easily. .head 4 - ! The wParam = ID_xxx is synonymous with the item in the contents section of the outline. .head 4 - ! (Remember that when we created the combo box we gave each one a unique ID. IDs 0 - 255 .head 4 - ! are available for our use in a SQLWindows application.) .head 4 - ! Similarly, each If hiWord= CBN_xxx is similar to the On SAM_xxx Message Actions .head 4 - ! section in the outline. (CBN stands for Combo Box Notification, in case you were .head 4 - ! wondering.) .head 4 + If wParam = IDC_SIMPLE .head 5 - Set hiWord = ( lParam & 0xFFFF0000) / 0x10000 .head 5 + If hiWord = CBN_SELCHANGE .head 6 - ! this message is similar to the SAM_Click message that a list box receives. .head 6 - Set nIndex = ComboBoxQuerySelection( hWndComboBoxSimple ) .head 6 + If nIndex != CB_ERR .head 7 - Call SalGetWindowText( hWndComboBoxSimple, sRetString, 30 ) .head 7 - Call SalStrSetBufferLength( sSelText, 30 ) .head 7 + If ComboBoxQueryText( hWndComboBoxSimple, nIndex, sSelText ) = CB_ERR .head 8 - Call SalMessageBeep( 0 ) .head 8 - Call SalMessageBox( 'Error returned from ComboBox Call!','Demo',MB_Ok|MB_IconHand ) .head 7 + Else .head 8 + If sSelText != sRetString .head 9 + If ComboBoxFindString( hWndComboBoxSimple, -1, sRetString ) = CB_ERR .head 10 - Call ComboBoxAdd( hWndComboBoxSimple, sRetString ) .head 9 + Else .head 10 - Call SalMessageBox( 'You have selected: '||sSelText, 'CBS_SIMPLE: Demo', MB_Ok ) .head 8 + Else .head 9 - Call SalMessageBox( 'You have selected: '||sSelText, 'Test Combo Box', MB_Ok ) .head 6 + Else .head 7 - Call SalMessageBeep( 0 ) .head 7 - Call SalMessageBox( 'Error returned from ComboBox Call!','Demo',MB_Ok|MB_IconHand ) .head 7 - Return FALSE .head 6 - Return TRUE .head 5 + Else If hiWord = CBN_SETFOCUS .head 6 - ! process this message if you want to do something when the user sets the focus .head 6 - ! to the combo box .head 6 - Return TRUE .head 5 + Else If hiWord = CBN_KILLFOCUS .head 6 - ! process this message if you want to do something when the user moves the focus .head 6 - ! away from the combobox .head 6 - Return TRUE .head 5 + Else If hiWord = CBN_EDITCHANGE .head 6 - ! process this message if you want to take action after the user has done something .head 6 - ! to update the display. It is similar to the SAM_AnyEdit message. Unlike the .head 6 - ! next message, however, this message is sent *after* Windows updates the display. .head 6 - Return TRUE .head 5 + Else If hiWord = CBN_EDITUPDATE .head 6 - ! process this message if you want to take action after the user has done something .head 6 - ! to update the display. It is similar to the SAM_AnyEdit message. Unlike the .head 6 - ! previous message, Windows sends this message *before* displaying any user updates. .head 6 - Return TRUE .head 5 + Else If hiWord = CBN_DROPDOWN .head 6 - ! windows sends this notification message when the user presses the down button .head 6 - ! of a dropdown control but *before* the list box is made visible. .head 6 - Return TRUE .head 5 + Else .head 6 - Return FALSE .head 4 + If wParam = IDC_DROPDOWNLIST .head 5 - Set hiWord = ( lParam & 0xFFFF0000) / 0x10000 .head 5 + If hiWord = CBN_SELCHANGE .head 6 - Set nIndex = ComboBoxQuerySelection( hWndComboBoxDropDownList ) .head 6 + If nIndex != CB_ERR .head 7 - Call SalStrSetBufferLength( sSelText, 30 ) .head 7 - Call ComboBoxQueryText( hWndComboBoxDropDownList, nIndex, sSelText ) .head 7 - Call SalMessageBox( 'You have selected: '||sSelText, 'CBS_DROPDOWNLIST: Demo', MB_Ok ) .head 6 + Else .head 7 - Call SalMessageBeep( 0 ) .head 7 - Call SalMessageBox( 'Error returned from ComboBox Call!','Demo',MB_Ok|MB_IconHand ) .head 7 - Return FALSE .head 6 - Return TRUE .head 5 + Else .head 6 - Return FALSE .head 4 + If wParam = IDC_DROPDOWN .head 5 - Set hiWord = ( lParam & 0xFFFF0000) / 0x10000 .head 5 + If hiWord = CBN_SELCHANGE .head 6 - ! this message is similar to the SAM_Click message that a list box receives. .head 6 - Set nIndex = ComboBoxQuerySelection( hWndComboBoxDropDown ) .head 6 + If nIndex != CB_ERR .head 7 - Call SalGetWindowText( hWndComboBoxDropDown, sRetString, 30 ) .head 7 - Call SalStrSetBufferLength( sSelText, 30 ) .head 7 + If ComboBoxQueryText( hWndComboBoxDropDown, nIndex, sSelText )= CB_ERR .head 8 - Call SalMessageBeep( 0 ) .head 8 - Call SalMessageBox( 'Error returned from ComboBox Call!','Demo',MB_Ok|MB_IconHand ) .head 7 + Else .head 8 + If sSelText != sRetString .head 9 + If ComboBoxFindString( hWndComboBoxDropDown, -1, sRetString ) = CB_ERR .head 10 - Call ComboBoxAdd( hWndComboBoxDropDown, sRetString ) .head 9 + Else .head 10 - Call SalMessageBox( 'You have selected: '||sSelText, 'CBS_DROPDOWN: Demo', MB_Ok ) .head 8 + Else .head 9 - Call SalMessageBox( 'You have selected: '||sSelText, 'CBS_DROPDOWN: Demo', MB_Ok ) .head 6 + Else .head 7 - Call SalMessageBeep( 0 ) .head 7 - Call SalMessageBox( 'Error returned from ComboBox Call!','Demo',MB_Ok|MB_IconHand ) .head 7 - Return FALSE .head 6 - Return TRUE .head 5 + Else .head 6 - Return FALSE .head 1 + Dialog Box: dlgAbout .head 2 - Title: About ComboBox Demo... .head 2 + Display Settings .head 3 - Visible at Design time? No .head 3 - Type of Dialog: Modal .head 3 + Window Location and Size .head 4 - Left: 0.357" .head 4 - Top: 0.292" .head 4 - Width: 8.186" .head 4 - Height: 4.073" .head 3 - Absolute Screen Location? No .head 2 + Contents .head 3 + Multiline Field: mfAboutText .head 4 + Data .head 5 - Maximum Data Length: Default .head 5 - String Type: String .head 5 - Editable? No .head 4 + Display Settings .head 5 - Border? Yes .head 5 - Word Wrap? Yes .head 5 - Vertical Scroll? Yes .head 5 + Window Location and Size .head 6 - Left: 0.186" .head 6 - Top: 0.156" .head 6 - Width: 7.5" .head 6 - Height: 3.083" .head 5 - Visible? Yes .head 4 + Message Actions .head 5 + On SAM_Create .head 6 - Set mfAboutText = ABOUT_TEXT .head 3 + Pushbutton: pbWOW .head 4 - Title: Kowabunga, Dude! .head 4 + Window Location and Size .head 5 - Left: 2.786" .head 5 - Top: 3.344" .head 5 - Width: 2.3" .head 5 - Height: 0.292" .head 4 - Visible? Yes .head 4 - Keyboard Accelerator: Enter .head 4 + Message Actions .head 5 + On SAM_Click .head 6 - Call SalEndDialog( hWndForm, TRUE ) .head 5 + On SAM_Create .head 6 - Call SalSetFocus( hWndItem ) .head 5 + On WM_LBUTTONDOWN .head 6 - Call SalGetWindowText( hWndItem, sButtonText, 20 ) .head 6 - Call SalSetWindowText( hWndItem, 'Surf\'s Up!') .head 5 + On WM_LBUTTONUP .head 6 - Call SalSetWindowText( hWndItem, sButtonText ) .head 2 - Window Variables .head 2 - Message Actions